<form lay-filter="processInfoForm" class="layui-form model-form">
  <input name="id" type="hidden" />
  <div class="layui-form-item">
    <div class="layui-col-md12">
      <label class="layui-form-label" style="width: 100px">选择工序</label>
      <div class="layui-input-block" style="margin-left: 130px; width: 70%">
        <!-- <select id="nodeTypes" name="nodeTypes" lay-filter="nodeTypes" lay-search ></select> -->
        <input type="text" class="layui-input" name="processName" lay-filter="processName" disabled lay-search />
        <input type="hidden" name="processId" lay-filter="processId" lay-search />
      </div>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-col-md12">
      <label class="layui-form-label" style="width: 100px">异常原因名称</label>
      <div class="layui-input-block" style="margin-left: 130px; width: 70%">
        <input class="layui-input" type="text" name="name" lay-search />
      </div>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-col-md12">
      <label class="layui-form-label" style="width: 100px">异常原因代码</label>
      <div class="layui-input-block" style="margin-left: 130px; width: 70%">
        <input class="layui-input" type="text" name="code" lay-search />
      </div>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-col-md12">
      <label class="layui-form-label" style="width: 100px">描述</label>
      <div class="layui-input-block" style="margin-left: 130px; width: 70%">
        <input class="layui-input" type="text" name="remark" lay-search />
      </div>
    </div>
  </div>

  <div class="layui-form-item">
    <div class="layui-col-md12">
      <label class="layui-form-label" style="width: 100px">状态</label>
      <div class="layui-input-block" style="margin-left: 130px; width: 70%">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="status" title="启用|停用" />
      </div>
    </div>
  </div>

  <div class="layui-form-item text-right">
    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    <button class="layui-btn" lay-filter="processInfoFormSubmit" type="button" lay-submit>添加</button>
  </div>
</form>
<script>
  layui.use(["form", "admin", "layer", "table"], function () {
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var table = layui.table;

    const nowData = { ...parentData };
    let data = nowData.data;
    if (!data.processId) {
      data.processId = data.id;
    }
    if (data.nodeNames) {
      data.id = "";
    }
    if (data.nodeNames) {
      data.processName = data.nodeNames;
    }
    if (data.status == "1") {
      data.status = "on";
    } else {
      data.status ='';
    }
    form.val("processInfoForm", data);
    form.on("submit(processInfoFormSubmit)", function (data) {
      let formData = data.field;
      if (formData.status) {
        formData.status = "1";
      } else {
        formData.status = "2";
      }
      console.log(formData);

      layer.load(2);
      admin.req(
        formData.id ? "enterprise/product/admin/processInfo/updateQualitySet" : "enterprise/product/admin/processInfo/addQualitySet",
        JSON.stringify(formData),
        function (res) {
          layer.closeAll("loading");
          if (res.code == 200) {
            layer.msg(res.msg, { icon: 1 });
            table.reload("processInfoTableList");
            layer.close(nowData.zindex);
          } else {
            layer.msg(res.msg, { icon: 2 });
          }
        },
         "POST",
        true,
        "application/json; charset=utf-8"
      );
      return false;
    });
  });
</script>
